﻿using System;
using System.Collections.Generic;
using System.Text;
using WMS.IDAL;
using WMS.Entity;

namespace WMS.BLL
{
    public class Category
    {
        private static readonly ICategory dal = WMS.DAL.Factory.DataAccess.CreateCategoryObject();

        public IList<CategoryEntity> GetAllList()
        {
            return dal.GetAllList();
        }

        /// <summary>
        /// 获取全部，没有删除的
        /// </summary>
        /// <returns></returns>
        public IList<CategoryEntity> GetAllListWithoutDeleted()
        {
            #region
            IList<CategoryEntity> entityList = new List<CategoryEntity>();
            IList<CategoryEntity> tempList = dal.GetAllList();

            foreach (CategoryEntity entity in tempList)
            {
                if (entity.IsDeleted == 0)
                {
                    entityList.Add(entity);
                }
            }

            return entityList;
            #endregion
        }

        public CategoryEntity GetCategory(int categoryID)
        {
            return dal.GetEntity(categoryID);
        }

        public void Delete(int categoryID)
        {
            dal.Delete(categoryID);
        }

        public void Add(CategoryEntity entity)
        {
            dal.Add(entity);
        }

        public void Update(CategoryEntity entity)
        {
            dal.Update(entity);
        }

        public int GetMaxID()
        {
            return dal.GetMaxID();
        }
    }
}
